package com.ghxxzx.dagl.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ghxxzx.dagl.entity.Daxx;
import com.ghxxzx.dagl.entity.GryfKj;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 刘华
 * @Date: 2020/11/16 11:02
 * @Version 1.0
 */
@Repository
public interface GryfKjMapper extends BaseMapper<GryfKj> {
    @Select("SELECT * FROM `gryf_kj` where dabh=#{dabh} LIMIT 1")
    GryfKj findByDabh(String dabh);

    @Select("SELECT MAX(year) FROM gryf_kj")
    String findByMaxYear();

    @Select("SELECT `year` FROM gryf_kj WHERE type_id=${typeId} GROUP BY `year`")
    ArrayList<String> findGroupByYear(@Param("typeId") Integer typeId);

    @Select("SELECT type_id FROM gryf_kj WHERE dabh=#{dabh}")
    Integer findByDanbh(@Param("dabh")String dabh);

//    @Select("<script> SELECT * FROM gryf_kj WHERE MATCH(year,zhh,zys,qsym,zzym,bz,sqcl,spsj,sqsx,sqr,village_jwh,town_bsc,dabh) against('+#{keyword}*' IN BOOLEAN MODE) and type_id in (" +
//            "<foreach collection='typeIds' separator=',' item='type_id'> #{type_id} </foreach> " +
//            ")</script>")
//    List<GryfKj> DajsKeyword(@Param("keyword")String keyword,@Param("typeIds")List<Integer> typeIds);

//    @Select(" SELECT * FROM gryf_kj WHERE MATCH(year,zhh,zys,qsym,zzym,bz,sqcl,spsj,sqsx,sqr,village_jwh,town_bsc,dabh) against('+#{keyword}*' IN BOOLEAN MODE) and type_id in (#{typeIds})")
//    List<GryfKj> DajsKeyword(@Param("keyword")String keyword,@Param("typeIds")String typeIds);

//    @Select("<script> SELECT * FROM gryf_kj WHERE MATCH(year,zhh,zys,qsym,zzym,bz,sqcl,spsj,sqsx,sqr,village_jwh,town_bsc,dabh) against('+#{keyword}*' IN BOOLEAN MODE) and year BETWEEN #{startYear} and #{stopYear} and type_id in (" +
//            "<foreach collection='typeIds' separator=',' item='type_id'> #{type_id} </foreach> " +
//            ")</script>")
//    List<GryfKj> DajsKeywordAndYear(@Param("keyword")String keyword,@Param("typeIds")List<Integer> typeIds,@Param("startYear")String startYear,@Param("stopYear")String stopYear);
}
